//
//  MyGalleryCollectionViewCell.m
//  parent
//
//  Created by IreWesT on 15/6/2.
//  Copyright (c) 2015年 ci123. All rights reserved.
//

#import "MyGalleryCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@implementation MyGalleryCollectionViewCell

- (id)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        _imageView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_imageView];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    
    [super setSelected:selected];
    [self setNeedsDisplay];
    
    if(selected)
    {
        [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionAllowUserInteraction animations:^{
            self.transform = CGAffineTransformMakeScale(0.97, 0.97);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseOut|UIViewAnimationOptionAllowUserInteraction animations:^{
                self.transform = CGAffineTransformIdentity;
            } completion:^(BOOL finished) {
                
            }];
        }];
    }
//    else
//    {
//        [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionAllowUserInteraction animations:^{
//            self.transform = CGAffineTransformMakeScale(1.03, 1.03);
//        } completion:^(BOOL finished) {
//            [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseOut|UIViewAnimationOptionAllowUserInteraction animations:^{
//                self.transform = CGAffineTransformIdentity;
//            } completion:^(BOOL finished) {
//                
//            }];
//        }];
//        
//    }
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    NSString *picString = [NSString stringWithFormat:@"%@%@", _picPrefix, _data[@"srcurl"]];
    [_imageView sd_setImageWithURL:[NSURL URLWithString:picString]];
}
    
@end
